﻿package mortal.game.view.market.sale
{
    import com.mui.controls.*;
    import flash.events.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class MarketSalePanel extends GSprite
    {
        private var _boxItem:GRadioButton;
        private var _boxCoin:GRadioButton;
        private var _boxGold:GRadioButton;
        private var _saleYuBao:MktSaleGlod;
        private var _saleJinbi:MktSaleCoin;
        private var _saleItem:MktSaleItem;
        private var _bag:MktBag;

        public function MarketSalePanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._boxItem = UIFactory.radioButton("寄售物品", 25, 63, 85, 28, this);
            this._boxCoin = UIFactory.radioButton("寄售金币", 115, 63, 85, 28, this);
            this._boxGold = UIFactory.radioButton("寄售钻石", 205, 63, 85, 28, this);
            this._boxItem.groupName = "MarketSaleRadioGroup";
            this._boxCoin.groupName = "MarketSaleRadioGroup";
            this._boxGold.groupName = "MarketSaleRadioGroup";
            this._bag = UIFactory.getUICompoment(MktBag, 355, 92, this);
            this._boxItem.configEventListener(Event.CHANGE, this.radioBtnChange);
            this._boxCoin.configEventListener(Event.CHANGE, this.radioBtnChange);
            this._boxGold.configEventListener(Event.CHANGE, this.radioBtnChange);
            Dispatcher.addEventListener(EventName.MarketPushSaleItem, this.onPushItem);
            this.onPushItem(null);
            return;
        }// end function

        private function onPushItem(event:DataEvent) : void
        {
            this._boxItem.selected = true;
            this.radioBtnChange(null);
            return;
        }// end function

        private function radioBtnChange(event:Event) : void
        {
            if (this._saleYuBao)
            {
                this._saleYuBao.visible = false;
            }
            if (this._saleItem)
            {
                this._saleItem.visible = false;
            }
            if (this._saleJinbi)
            {
                this._saleJinbi.visible = false;
            }
            if (this._boxItem.selected)
            {
                this.saleItem.visible = true;
            }
            if (this._boxCoin.selected)
            {
                this.saleJinbi.visible = true;
            }
            if (this._boxGold.selected)
            {
                this.saleYuBao.visible = true;
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._boxItem.dispose(param1);
            this._boxCoin.dispose(param1);
            this._boxGold.dispose(param1);
            this._bag.dispose(param1);
            this._boxItem = null;
            this._boxCoin = null;
            this._boxGold = null;
            this._bag = null;
            if (this._saleYuBao)
            {
                this._saleYuBao.dispose(param1);
                this._saleYuBao = null;
            }
            if (this._saleJinbi)
            {
                this._saleJinbi.dispose(param1);
                this._saleJinbi = null;
            }
            if (this._saleItem)
            {
                this._saleItem.dispose(param1);
                this._saleItem = null;
            }
            return;
        }// end function

        public function get saleItem() : MktSaleItem
        {
            if (this._saleItem == null)
            {
                this._saleItem = UIFactory.getUICompoment(MktSaleItem, 10, 92, this);
            }
            return this._saleItem;
        }// end function

        public function get saleJinbi() : MktSaleCoin
        {
            if (this._saleJinbi == null)
            {
                this._saleJinbi = UIFactory.getUICompoment(MktSaleCoin, 10, 92, this);
            }
            return this._saleJinbi;
        }// end function

        public function get saleYuBao() : MktSaleGlod
        {
            if (this._saleYuBao == null)
            {
                this._saleYuBao = UIFactory.getUICompoment(MktSaleGlod, 10, 92, this);
            }
            return this._saleYuBao;
        }// end function

    }
}
